home *** CD-ROM | disk | FTP | other *** search
- /* Str routines */
- # include <Dialogs.h>
- # include <Events.h>
- # include <Menus.h>
- # include "tonto.h"
-
- void
- SetNameStr (name, line)
- StringPtr name;
- StringPtr line;
- /* Gets the named string & sets it to line. If not found, creates it*/
- {
- Handle myHndl;
- Str255 s;
- Size len;
-
- len = (Size) line[0] + 1;
- myHndl = GetNamedResource ('STR ', (SP) name);
- if (myHndl == NULL)
- {
- myHndl = NewHandle (len);
- if (!myHndl)
- return;
- pstrcpy ((SP)(*myHndl), line);
- AddResource (myHndl, 'STR ', UniqueID('STR '), (SP)name);
- }
- else
- {
- HNoPurge (myHndl);
- SetHandleSize (myHndl, len);
- pstrcpy ((SP)(*myHndl), line);
- ChangedResource(myHndl);
- HPurge (myHndl);
- }
- WriteResource (myHndl);
- }
-
- int
- GetNamedStr (name, line)
- /* returns 0 if not found, 1 if found */
- StringPtr name;
- StringPtr line;
- {
- Handle myHndl;
-
- myHndl = GetNamedResource ('STR ', (SP)name);
- if (!myHndl) {
- line[0] = 0;
- return(0);
- }
- pstrcpy (line, (SP)(*myHndl));
- return(1);
- }
-
- StringPtr
- pstrcpy (dest, src)
- StringPtr dest;
- StringPtr src;
- {
- BlockMove (src, dest, (Size)(src[0]) + 1);
- return dest;
- }
-
- StringPtr
- pstrcat (dest, src)
- StringPtr dest, src;
- {
- int lens, lend;
-
- lens = src[0];
- lend = dest[0];
- if (lens + lend < 255) {
- BlockMove (src + 1, dest + lend+1, (Size)lens);
- dest[0] = lens + lend;
- }
- return dest;
- }
-
- StringPtr
- pstrcat2 (dest, src1, src2)
- StringPtr dest, src1, src2;
- {
- if (dest != src1)
- pstrcpy (dest, src1);
- return (pstrcat (dest, src2));
- }